package j_graphics;

// ======================================================
// getColorEx
// make : pwg
// date : 2003
// note : 프레임에 마우스를 클릭하여 색깔 정보 얻어오기
//        2003. 미완성
// ======================================================

import java.awt.*;
import java.awt.event.*;

public class GetColorEx extends Frame {
	myMouseAdapter myM;
	myWindowAdapter myW;
	Graphics mg = null;

	public GetColorEx() {
		setVisible(true);
		mg = getGraphics();
		myM = new myMouseAdapter(mg);
		myW = new myWindowAdapter();

		addMouseListener(myM);
		addWindowListener(myW);
	}

	public void paint(Graphics g) {
		g.setColor(Color.red);
		g.fillRect(50, 50, 100, 100);

		g.setColor(Color.blue);
		g.fillRect(200, 200, 50, 50);
	}

	public static void main(String[] args) {
		GetColorEx f = new GetColorEx();
		f.setSize(300, 300);
		f.setVisible(true);
	}

	class myMouseAdapter extends MouseAdapter {
		Graphics g;

		public myMouseAdapter(Graphics gg) {
			g = gg;
		}

		public void mouseClicked(MouseEvent e) {
			int x, y;
			x = e.getX();
			y = e.getY();

			System.out.println(mg.getColor());

		}
	};

	class myWindowAdapter extends WindowAdapter {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	};

}
